import {
  Controller,
  Get,
  Post,
  Body,
  Patch,
  Param,
  Delete,
  Query,
} from '@nestjs/common';
import { NestjsService } from './nestjs.service';

@Controller('nest')
export class NestjsController {
  constructor(private readonly nestjsService: NestjsService) {}

  @Post('save')
  save(@Body() createNestjDto: any) {
    console.log('save', createNestjDto);
    return this.nestjsService.save(createNestjDto);
  }

  @Get('find')
  async find(@Query('id') id: string) {
    console.log('find', id, await this.nestjsService.find({ id }));
    return {
      data: await this.nestjsService.find({ id }) || 'none'
    };
  }

  @Post('savetest')
  savetest(@Body() createNestjDto: any) {
    console.log('savetest', createNestjDto);
    return this.nestjsService.savetest(createNestjDto);
  }

  @Get('findtest')
  async findtest(@Query('id') id: string) {
    console.log('findtest', id, await this.nestjsService.findtest({ id }));
    return {
      data: await this.nestjsService.findtest({ id }) || 'none'
    };
  }

  @Get('findList')
  async findList() {
    return {
      data: await this.nestjsService.findList()
    };
  }

  // @Post()
  // create(@Body() createNestjDto: any) {
  //   return this.nestjsService.create();
  // }

  // @Get(':id')
  // findOne(@Param('id') id: string) {
  //   return this.nestjsService.findOne(+id);
  // }

  // @Patch(':id')
  // update(@Param('id') id: string, @Body() updateNestjDto: any) {
  //   return this.nestjsService.update(+id);
  // }

  // @Delete(':id')
  // remove(@Param('id') id: string) {
  //   return this.nestjsService.remove(+id);
  // }
}
